package com.crm.service.statisticAnalysis.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.crm.model.statisticAnalysis.dtos.DoughnutChartDTO;
import com.crm.model.statisticAnalysis.pojos.ClientStatistics;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface ClientMapper extends BaseMapper<ClientStatistics> {

    /**
     * 新增用户统计
     * @param beginTime
     * @param endTime
     * @return
     */
    @Select("select count(id) from crm_client_statistics where bargain_time > #{beginTime} and bargain_time < #{endTime}")
    Integer newClientCount(LocalDateTime beginTime, LocalDateTime endTime);

    /**
     * 统计总用户数
     * @param beginTime
     * @param endTime
     * @return
     */
    @Select("select count(id) from  crm_client_statistics where bargain_time < #{endTime}")
    Integer totalClientCount(LocalDateTime beginTime, LocalDateTime endTime);

    /**
     * 查询学科对应每天新增客户
     * @param beginTime
     * @param endTime
     * @return
     */
    List<DoughnutChartDTO> getSubjectNews(@Param("beginTime") LocalDateTime beginTime, @Param("endTime") LocalDateTime endTime);
}
